<template>
	<view class="page-view">
		<view class="block">
			<view class="title">
				即开名称
			</view>
			<picker @change="bindPickerChange" :value="index" :range="array" range-key="name">
				<view class="input-option">
					<input class="input-class" placeholder-class="pls" :disabled="true" v-model="param.typeName"
						placeholder="请选择即开类型" />
				</view>
			</picker>
		</view>
		<view class="block">
			<view class="title">
				销售数量
			</view>
			<view class="input-option">
				<input class="input-class" placeholder-class="pls" type="number" v-model="param.amount" placeholder="请输入你的销售金额" />
			</view>
		</view>
		<view class="block">
			<view class="title">
				销售金额
			</view>
			<view class="input-option">
				<input class="input-class" placeholder-class="pls" v-model="param.money" placeholder="请输入你的销售金额" />
			</view>
		</view>

		<view class="block">
			<view class="title">
				备注信息
			</view>
			<view class="txt-area-block">
				<textarea class="txt-area" v-model="param.remark" placeholder-class="pls"
					placeholder="请输入备注信息"></textarea>
			</view>
		</view>


		<view class="submit">
			<view class="btn-submit cancel" @click="clearClick">
				重置
			</view>

			<view class="btn-submit" @click="submitClick">
				确认
			</view>
		 
		</view>
	</view>
</template>

<script>
 
	export default {
		data() {
			return {
				array: [],
				index: 0,
				param: {
					typeName: '',
					money: '',
					remark: '',
					amount:'',
				}
			}
		},
		onShow() {
			this.initType()
		},
		
		methods: {
			bindPickerChange(e) {
				this.index = e.detail.value
				this.param.typeName = this.array[this.index].name
			},
			initType() {
				this.$http('manageMent.getInstantTakeType', {
					token: this.$tools.getToken(),
				}).then(res => {
					console.log('res=======>', res)
					if (res.code == 200) {
						this.array = res.data.list
					}
				})
			},
			clearClick() {
				this.param.typeName = ''
				this.param.money = ''
				this.param.remark = ''
				this.param.amount = ''
			},
			submitClick() {
				if (!this.param.typeName) {
					this.$tools.showMsg('即开类型不能为空')
					return
				}
				if (!this.param.money) {
					this.$tools.showMsg('金额不能为空')
					return
				}
				if (this.param.amount<=0) {
					this.$tools.showMsg('数量不能为空')
					return
				}
			 
				this.$http('manageMent.instantTakeRecord', {
					...this.param,
					token: this.$tools.getToken(),
				}).then(res => {
					if (res.code == 200) {
						this.$tools.showMsg('添加成功')
						setTimeout(res => {
							this.$tools.pagesBack()
						}, 600)
					}
					console.log('res======', res)
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #F8F9FD;
	}

	.block {
		margin-top: 20rpx;
		background: #fff;
		border-radius: 8rpx;
		padding-bottom: 36rpx;

		.title {
			margin-left: 24rpx;
			font-weight: bold;
			font-size: 30rpx;
			color: #020B00;
			padding: 28rpx 0;
		}

		.title-option {
			margin-left: 24rpx;
			margin-right: 24rpx;
			padding: 28rpx 0;
			display: flex;
			align-items: center;

			.left-txt {
				flex: auto;
				color: #020B00;
				font-weight: bold;
				font-size: 30rpx;
			}

			.right-hint-txt {
				flex: none;
				color: #1B8BF6;
				font-size: 24rpx;

				span {
					font-size: 34rpx;
					color: #1B8BF6;
				}
			}
		}

		.input-option {
			margin-left: 24rpx;
			margin-right: 24rpx;
			height: 88rpx;
			background: rgba(244, 245, 252, 0.7);
			border-radius: 8rpx;
			display: flex;
			align-items: center;

			.pls {
				font-weight: 400;
				font-size: 24rpx;
				color: #999999;
			}

			.input-class {
				margin-left: 24rpx;
			}
		}

		.txt-area-block {
			margin-left: 24rpx;
			margin-right: 24rpx;
			height: 328rpx;
			background: rgba(244, 245, 252, 0.7);
			border-radius: 8rpx;
			padding: 32rpx 24rpx 24rpx 24rpx;
			display: flex;

			.icon {
				width: 26rpx;
				height: 26rpx;
			}

			.txt-area {
				margin-left: 24rpx;

			}

			.pls {
				font-weight: 400;
				font-size: 24rpx;
				color: #999999;
			}
		}

		.imgs-block {
			margin-left: 24rpx;
			margin-right: 24rpx;
			margin-top: 34rpx;
			display: flex;
			align-items: center;
			flex-wrap: wrap;

			.upload-block {
				margin-bottom: 24rpx;
				margin-right: 18rpx;
				background: rgba(244, 245, 252, 0.7);
				width: 168rpx;
				height: 168rpx;
				border-radius: 8rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				.txt {
					margin-top: 16rpx;
					font-weight: 400;
					font-size: 22rpx;
					color: #9E9E9E;
				}
			}

			.img-block {
				margin-bottom: 24rpx;
				margin-right: 18rpx;
				width: 168rpx;
				height: 168rpx;
				border-radius: 8rpx;
				background: skyblue;
			}
		}


	}

	.submit {
		margin-left: 42rpx;
		margin-right: 42rpx;
		margin-top: 94rpx;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		display: flex;
		align-items: center;
		justify-content: space-evenly;

		.btn-submit {
			display: flex;
			align-items: center;
			justify-content: center;
			color: #FFFFFF;
			font-size: 30rpx;
			width: 226rpx;
			height: 76rpx;
			border-radius: 8rpx;
			background: linear-gradient(153deg, #69C5FD 0%, #0089CF 63%);
		}

		.cancel {
			background: #fff;
			color: #7ABCF4;
			border: 1rpx solid #7ABCF4;
		}

		.check-login-fn {
			font-weight: 500;
			text-align: center;
			margin-top: 20rpx;
			font-size: 28rpx;
			color: #FF6E15;
		}
	}
</style>